package com.tian.controller.api;

import com.tian.common.CommonResult;
import com.tian.dto.AppChargingStopReqDto;
import com.tian.dto.ChargingStartReqDto;
import com.tian.dto.ChargingStopReqDto;
import com.tian.service.ChargeRecordService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * {@code @description:} 充电业务控制层
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-29 20:15
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/charging/core")
public class ChargingController {

    @Resource
    private ChargeRecordService chargeRecordService;
    @GetMapping("/start/{gunNo}")
    public CommonResult<Boolean> start(@PathVariable("gunNo") String gunNo) {
        ChargingStartReqDto chargingStartReqDto = new ChargingStartReqDto();
        chargingStartReqDto.setGunNo(gunNo);
        chargeRecordService.startCharge(chargingStartReqDto);
        return CommonResult.success();
    }

    @GetMapping("/stop/{id}")
    public CommonResult<Boolean> stop(@PathVariable("id") Long id) {
        ChargingStopReqDto chargingStopReqDto = new ChargingStopReqDto();
        chargingStopReqDto.setChargingRecordId(id);
        return chargeRecordService.stopCharge(chargingStopReqDto);
    }
}
